package davion.study.jwtlearn.util;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import davion.study.jwtlearn.pojo.User;

/**
 * @author: Davion
 * @date: 2020.6.22
 * @description:
 */
public class JwtUtil {
    private JwtUtil(){}
    private static JwtUtil instance = new JwtUtil();
    public static JwtUtil getInstance(){
        return instance;
    }
    public String getToken(User user){
        String token;
        token = JWT.create().withAudience(user.getId())
                .sign(Algorithm.HMAC256(user.getPassword()));
        return token;
    }
}
